
var baseUrl = "http://qlapi.sylu.edu.cn/mock/67"
var  firstStatus = [0];

function skipregister() {
  window.location.href = "Register.html";
}

function enter() {

    var slf = null;
    try
    {
        slf = new XMLHttpRequest();
    }
    catch (error)
    {
        slf = new ActiveXObject("Microsoft,XMLHTTP");
    }


    if(firstStatus[0] == 1) return false;

    let username = document.getElementById("username").value;
    let password = document.getElementById("password").value;
    let _value = `username=${username} &password=${password}`;

    slf.open("post",`${baseUrl}/login`,true);
    slf.setRequestHeader("content-type","application/x-www-form-urlencoded");
    slf.send(`${_value}`);
    slf.oneraedystatechange = function()
    {
        if(slf.readyState == 4)
        {
            if(slf.status == 200)
            {
                const res = JSON.parse(slf.responeTest);
                Text.innerText = res.msg;
                console.log(res);
                function demo()
                {
                    window.location.href="login.html";
                }
                setTimeout(demo,500);
            }
            else 
            {
                alert("Error:"+slf.status);
            }
        }
    }


  }

